package com.hnkywl.sts.entity.jhgl;

import com.hnkywl.sts.entity.BaseEntity;
import com.hnkywl.sts.entity.base.Sjzdz;
import com.hnkywl.sts.entity.htgl.Cght;
import com.hnkywl.sts.entity.organ.Gsjg;
import com.hnkywl.sts.entity.organ.Nbbm;
import com.hnkywl.sts.entity.organ.Nbgs;
import com.hnkywl.sts.entity.organ.Qyjg;
import com.hnkywl.sts.entity.sfgl.Sfk;
import com.hnkywl.sts.entity.sfgl.Sfkmx;
import com.hnkywl.sts.entity.sys.Yg;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: ZHUCHG
 * Date: 13-5-24
 * Time: 上午9:43
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "T_BIZ_JKD")
@Where(clause = "deleted!='1'")
public class Jkd extends BaseEntity {
    @Id
    @SequenceGenerator(name = "seqJkd", allocationSize = 1, sequenceName = "SEQ_BIZ_JKD")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "seqJkd")
    private Long id;
    // 电子借款单编码/单号
    private String jkdbm;
    //zg:自购  tp:统配
    private String type;
    //采购合同
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "CGHT_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Cght cght;

    //供应商
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "GYS_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Qyjg gys;
    //支付款项
    private String zfkx;
    //支付金额
    private Double zfje = 0d;
    //已付金额
    private Double yfje = 0d;
    //本次付款
    private Double bcfk = 0d;
    //支付方式
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SJZDZ_ZFFS_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Sjzdz zffs;
    //支付时间
    private Date zfsj;

    //申报公司
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SBGS_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Nbgs sbgs;

    //申报部门
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SBBM_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Nbbm sbbm;
    //申请人
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SBR_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Yg sbr;

    //借款公司
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "JKGS_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Nbgs jkgs;
    //借款机构(部门)
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "JKJG_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Gsjg jkjg;
    //申请人
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SQR_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Yg sqr;
    //自购资金计划
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ZGZJJH_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Zgzjjh zgzjjh;
    //统配资金计划
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "TPZJJH_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Tpzjjh tpzjjh;

    //备注
    private String bz;


    @OneToMany(fetch = FetchType.LAZY, targetEntity = Sfkmx.class, mappedBy = "jkd")
    @NotFound(action = NotFoundAction.IGNORE)
    private List<Sfkmx> sfkmxList;

    //审批状态（已保存，已提交，已审批）   ybc ytj ysp
    private String zt = "ybc";

    // 关联流程
    @Column(name = "LC_ID")
    private String processInstanceId;

    //是否正在付款  zfk  正付款  yfk 已付款  fkwb  付款完毕 wsy
    private String sfzfk = "wsy";

    //乐观锁使用字段
    @Version
    private Integer version;

    //审批人
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "SPR_ID")
    @NotFound(action = NotFoundAction.IGNORE)
    private Yg spr;

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getJkdbm() {
        return jkdbm;
    }

    public void setJkdbm(String jkdbm) {
        this.jkdbm = jkdbm;
    }

    public BigDecimal getYfje() {
        BigDecimal bigDecimal = new BigDecimal(yfje == null ? 0 : yfje);
        return bigDecimal;
    }

    public void setYfje(Double yfje) {
        this.yfje = yfje;
    }

    public BigDecimal getBcfk() {
        BigDecimal bigDecimal = new BigDecimal(bcfk == null ? 0 : bcfk);
        return bigDecimal;
    }

    public void setBcfk(Double bcfk) {
        this.bcfk = bcfk;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Cght getCght() {
        return cght;
    }

    public void setCght(Cght cght) {
        this.cght = cght;
    }

    public Qyjg getGys() {
        return gys;
    }

    public void setGys(Qyjg gys) {
        this.gys = gys;
    }

    public String getZfkx() {
        return zfkx;
    }

    public void setZfkx(String zfkx) {
        this.zfkx = zfkx;
    }

    public BigDecimal getZfje() {
        DecimalFormat format = new DecimalFormat("0.00");
        BigDecimal bigDecimal = new BigDecimal(zfje == null ? 0 : zfje);
        return bigDecimal;
    }

    public void setZfje(Double zfje) {
        this.zfje = zfje;
    }

    public Sjzdz getZffs() {
        return zffs;
    }

    public void setZffs(Sjzdz zffs) {
        this.zffs = zffs;
    }

    public Date getZfsj() {
        return zfsj;
    }

    public void setZfsj(Date zfsj) {
        this.zfsj = zfsj;
    }

    public Nbgs getSbgs() {
        return sbgs;
    }

    public void setSbgs(Nbgs sbgs) {
        this.sbgs = sbgs;
    }

    public Nbbm getSbbm() {
        return sbbm;
    }

    public void setSbbm(Nbbm sbbm) {
        this.sbbm = sbbm;
    }

    public Yg getSbr() {
        return sbr;
    }

    public void setSbr(Yg sbr) {
        this.sbr = sbr;
    }

    public Nbgs getJkgs() {
        return jkgs;
    }

    public void setJkgs(Nbgs jkgs) {
        this.jkgs = jkgs;
    }

    public Gsjg getJkjg() {
        return jkjg;
    }

    public void setJkjg(Gsjg jkjg) {
        this.jkjg = jkjg;
    }

    public Yg getSqr() {
        return sqr;
    }

    public void setSqr(Yg sqr) {
        this.sqr = sqr;
    }

    public Zgzjjh getZgzjjh() {
        return zgzjjh;
    }

    public void setZgzjjh(Zgzjjh zgzjjh) {
        this.zgzjjh = zgzjjh;
    }

    public Tpzjjh getTpzjjh() {
        return tpzjjh;
    }

    public void setTpzjjh(Tpzjjh tpzjjh) {
        this.tpzjjh = tpzjjh;
    }

    public String getBz() {
        return bz;
    }

    public void setBz(String bz) {
        this.bz = bz;
    }

    public List<Sfkmx> getSfkmxList() {
        return sfkmxList;
    }

    public void setSfkmxList(List<Sfkmx> sfkmxList) {
        this.sfkmxList = sfkmxList;
    }

    public String getZt() {
        return zt;
    }

    public void setZt(String zt) {
        this.zt = zt;
    }

    public String getProcessInstanceId() {
        return processInstanceId;
    }

    public void setProcessInstanceId(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }

    public String getSfzfk() {
        return sfzfk;
    }

    public void setSfzfk(String sfzfk) {
        this.sfzfk = sfzfk;
    }

    public Yg getSpr() {
        return spr;
    }

    public void setSpr(Yg spr) {
        this.spr = spr;
    }
}
